//
//  AppDelegate.swift
//  OCSSStoreSwift
//
//  Created by MacMiniKangChe on 2018/10/11.
//  Copyright © 2018年 MacMiniKangChe. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        NotificationCenter.default.addObserver(self, selector: #selector(reloadRootVC(notify: )), name: NSNotification.Name(kReloadRootPage), object: nil);
        self.window = UIWindow.init(frame: UIScreen.main.bounds);
        if (IsLogin != nil && (IsLogin as! Bool)) {
            let rootVC = OCSSMainTabBarPage.init();
            self.window?.rootViewController = rootVC;
        }else{
            let loginPage = OCSSLoginPage.init();
            self.window?.rootViewController = loginPage;
        }
        
        self.window?.backgroundColor = UIColor.white;
        self.window?.makeKeyAndVisible();
        
        return true
    }
    @objc func reloadRootVC(notify:NSNotification) -> Void {
        let isLogin = notify.object as! Bool;
        if isLogin {
            let rootVC = OCSSMainTabBarPage.init();
            self.window?.rootViewController = rootVC;
        }else{
            let loginPage = OCSSLoginPage.init();
            self.window?.rootViewController = loginPage;
        }
    }
    func applicationWillResignActive(_ application: UIApplication) {
        
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        
    }
    func applicationDidBecomeActive(_ application: UIApplication) {
        
    }

    func applicationWillTerminate(_ application: UIApplication) {
        
    }


}

